<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:p="clr-namespace:CDC.SampleShell.Presentation.Properties"
    xmlns:converters="clr-namespace:CDC.SampleShell.Applications.Converters;assembly=CDC.SampleShell.Applications"
    xmlns:local="clr-namespace:CDC.SampleShell.Presentation"
    xmlns:controls="clr-namespace:CDC.SampleShell.Presentation.Controls">

    <converters:TabDisplayConverter x:Key="TabDisplayConverter" />
    <converters:BooleanInverter x:Key="BooleanInverter" />

    <SolidColorBrush x:Key="ThemeBrush" Color="#0072C6" />
    <SolidColorBrush x:Key="ThemeLightBrush" Color="#2A8DD4" />

    <!--  min/max/restore button style -->
    <Style TargetType="{x:Type Button}" x:Key="WindowButtonStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <Border
                            x:Name="Chrome"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Padding="6, 0, 6, 0"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="True">
                        <ContentPresenter
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                Content="{TemplateBinding Content}"
                                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                Margin="{TemplateBinding Padding}"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="FontFamily" Value="Webdings"/>
        <Setter Property="FontSize" Value="15" />
        <Setter Property="Foreground" Value="#777777" />
        <Setter Property="Margin" Value="0,2,3,0"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="#2A8DD4" />
                <Setter Property="Background" Value="#CDE6F7" />
            </Trigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type controls:CustomWindow}}, Path=IsActive}" Value="False">
                <Setter Property="Foreground" Value="#C6C6C6" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <!-- empty button style -->
    <Style TargetType="Button" x:Key="EmptyButtonStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <ContentPresenter />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- Window style -->
    <Style TargetType="{x:Type controls:CustomWindow}">
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource ResourceKey=ThemeBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:CustomWindow}">
                    <Border BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}">
                        <Grid Background="White">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>

                                <Rectangle x:Name="moveRectangle" Fill="Transparent"
                                           Grid.Row="0" Grid.Column="1"/>

                                <TextBlock x:Name="windowTitle" 
                                           Margin="5"
                                           IsHitTestVisible="False"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Center"
                                           Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type controls:CustomWindow}}, Path=Title}"
                                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type controls:CustomWindow}}, Path=IsActive}" Value="False">
                                                    <Setter Property="Foreground" Value="#C6C6C6" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>

                                <StackPanel Grid.Row="0" Grid.Column="2" Orientation="Horizontal">
                                    <Button x:Name="minimizeButton" Style="{StaticResource WindowButtonStyle}"
                                            Content="0" />
                                    <Button x:Name="restoreButton" Style="{StaticResource WindowButtonStyle}"
                                            Content="1" />
                                    <Button x:Name="closeButton" Style="{StaticResource WindowButtonStyle}"
                                            Content="r" />
                                </StackPanel>

                                <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
                                    <Button Style="{StaticResource EmptyButtonStyle}" Width="Auto" BorderBrush="Transparent" Background="Transparent" Margin="5, 0, 0, 0" HorizontalAlignment="Left">
                                        <Border CornerRadius="2" Background="{StaticResource ResourceKey=ThemeBrush}" Width="16" Height="16" HorizontalAlignment="Left">
                                            <TextBlock Text="EI" FontSize="10" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                        </Border>
                                    </Button>

                                    <Button 
                                        ToolTipService.HasDropShadow="True"
                                        ToolTipService.InitialShowDelay="0"
                                        Command="{Binding RepopulateCollectionsCommand}"
                                        Style="{StaticResource EmptyButtonStyle}" Width="Auto" BorderBrush="Transparent" Background="Transparent" Margin="10, 0, 0, 0" HorizontalAlignment="Left">
                                        <Button.ToolTip>
                                            <Border Padding="8">
                                                <StackPanel>
                                                    <Label FontWeight="Bold" Content="Refresh" />
                                                    <Label Content="Refreshes the data." />
                                                </StackPanel>
                                            </Border>
                                        </Button.ToolTip>
                                        <Border CornerRadius="2" Background="Transparent" Width="16" Height="16" HorizontalAlignment="Left">
                                            <Path Data="F1 M 38,20.5833C 42.9908,20.5833 47.4912,22.6825 50.6667,26.046L 50.6667,17.4167L 55.4166,22.1667L 55.4167,34.8333L 42.75,34.8333L 38,30.0833L 46.8512,30.0833C 44.6768,27.6539 41.517,26.125 38,26.125C 31.9785,26.125 27.0037,30.6068 26.2296,36.4167L 20.6543,36.4167C 21.4543,27.5397 28.9148,20.5833 38,20.5833 Z M 38,49.875C 44.0215,49.875 48.9963,45.3932 49.7703,39.5833L 55.3457,39.5833C 54.5457,48.4603 47.0852,55.4167 38,55.4167C 33.0092,55.4167 28.5088,53.3175 25.3333,49.954L 25.3333,58.5833L 20.5833,53.8333L 20.5833,41.1667L 33.25,41.1667L 38,45.9167L 29.1487,45.9167C 31.3231,48.3461 34.483,49.875 38,49.875 Z "
                                                  Stretch="Fill"
                                                  Width="13"
                                                  Height="16"
                                                  Fill="Silver" />
                                        </Border>
                                    </Button>

                                    <Button 
                                        ToolTipService.HasDropShadow="True"
                                        ToolTipService.InitialShowDelay="0"
                                        Style="{StaticResource EmptyButtonStyle}" Width="Auto" BorderBrush="Transparent" Background="Transparent" Margin="10, 0, 0, 0" HorizontalAlignment="Left">
                                        <Button.ToolTip>
                                            <Border Padding="8">
                                                <StackPanel>
                                                    <Label FontWeight="Bold" Content="Settings" />
                                                    <Label Content="Displays application data." />
                                                </StackPanel>
                                            </Border>
                                        </Button.ToolTip>
                                        <Border CornerRadius="2" Background="Transparent" Width="16" Height="16" HorizontalAlignment="Left">
                                            <Path Data="F1 M 27.5314,21.8628L 33.0126,19.4224L 34.7616,23.3507C 36.6693,22.9269 38.6044,22.8903 40.4668,23.2026L 42.0083,19.1868L 47.6098,21.337L 46.0683,25.3528C 47.6612,26.3669 49.0747,27.6889 50.2088,29.2803L 54.1371,27.5313L 56.5776,33.0126L 52.6493,34.7616C 53.0731,36.6693 53.1097,38.6043 52.7974,40.4668L 56.8131,42.0083L 54.6629,47.6097L 50.6472,46.0683C 49.6331,47.6613 48.3111,49.0748 46.7197,50.2089L 48.4686,54.1372L 42.9874,56.5776L 41.2384,52.6493C 39.3307,53.0731 37.3957,53.1097 35.5333,52.7974L 33.9918,56.8131L 28.3903,54.6629L 29.9318,50.6472C 28.3388,49.6331 26.9252,48.3111 25.7911,46.7196L 21.8628,48.4686L 19.4224,42.9873L 23.3507,41.2383C 22.9269,39.3307 22.8903,37.3957 23.2026,35.5332L 19.1869,33.9918L 21.3371,28.3903L 25.3528,29.9318C 26.3669,28.3388 27.6889,26.9252 29.2804,25.7911L 27.5314,21.8628 Z M 34.3394,29.7781C 29.7985,31.7998 27.7564,37.1198 29.7781,41.6606C 31.7998,46.2015 37.1198,48.2436 41.6606,46.2219C 46.2015,44.2002 48.2436,38.8802 46.2219,34.3394C 44.2002,29.7985 38.8802,27.7564 34.3394,29.7781 Z "
                                                  Stretch="Fill"
                                                  Width="16"
                                                  Height="16"
                                                  Fill="Silver" />
                                        </Border>
                                    </Button>
                                </StackPanel>

                                <Grid Background="{TemplateBinding Background}"
                                           Grid.Row="1" Grid.ColumnSpan="3" Margin="0,5,0,0">
                                    <AdornerDecorator>
                                        <ContentPresenter/>
                                    </AdornerDecorator>
                                </Grid>
                            </Grid>


                            <Grid x:Name="resizeGrid">
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            VerticalAlignment="Top"
            Height="5"
            x:Name="top"
            Margin="5,0,5,0" />
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            x:Name="bottom"
            Height="5"
            VerticalAlignment="Bottom"
            Margin="5,0,5,0" />
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            HorizontalAlignment="Left"
            Margin="0,5,0,5"
            Width="5"
            x:Name="left"/>
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            Margin="0,5,0,5"
            Width="5"
            HorizontalAlignment="Right"
            x:Name="right" />
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            HorizontalAlignment="Left"
            VerticalAlignment="Bottom"
            Width="5"
            Height="5"
            x:Name="bottomLeft" />
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            VerticalAlignment="Bottom"
            Height="5"
            Width="5"
            HorizontalAlignment="Right"
            x:Name="bottomRight" />
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            HorizontalAlignment="Right"
            Width="5"
            Height="5"
            VerticalAlignment="Top"
            x:Name="topRight" />
                                <Rectangle
            Stroke="{x:Null}"
            Fill="Transparent"
            HorizontalAlignment="Left"
            Width="6"
            VerticalAlignment="Top"
            Height="5"
            x:Name="topLeft" />
                            </Grid>


                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="Button" x:Key="TabButtonStyle">
        <Setter Property="Foreground" Value="{StaticResource ResourceKey=ThemeBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <ContentPresenter />

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource ResourceKey=ThemeLightBrush}" />
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Button" x:Key="FlatButtonStyle">
        <Setter Property="Foreground" Value="#DDDDDD" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="PART_Border" BorderThickness="0" Padding="4" Background="#555555">
                        <ContentPresenter HorizontalAlignment="Center" />
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="White" />
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type controls:SearchBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:SearchBox}">
                    <Grid>
                        <TextBox Text="{Binding RelativeSource={RelativeSource Self}, Path=Text}" x:Name="searchBox" Width="250" BorderBrush="{StaticResource ResourceKey=ThemeLightBrush}">
                            <TextBox.InputBindings>
                                <KeyBinding Key="Enter" Command="{Binding SearchRecordsCommand}" CommandParameter="{Binding ElementName=searchBox, Path=Text}" />
                            </TextBox.InputBindings>
                        </TextBox>
                        <TextBlock x:Name="searchBoxLabel" FontStyle="Italic" IsHitTestVisible="False" Foreground="Silver" Text="Search" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="6, 0, 0, 0" Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="searchBox" Value="" Property="Text">
                            <Setter TargetName="searchBoxLabel" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
